1. Field of the Invention
The present invention relates generally to converting grayscale images to raster images, and more particularly to smoothing images after such conversion.
2. Related Art
Legacy paper engineering drawings are often imported into computer memory so that they can be modified, used as a basis for creating new drawings, or for long-term electronic storage. To do so, the drawings are read on a scanner by a process that transforms the drawings into a digital raster image. Generally, engineering drawings are scanned in two colors, i.e. 1-bit color, usually black and white, because two-color drawings take less storage space and are more easily and more quickly manipulated by imaging software. Sometimes engineering drawings are scanned in 8-bit (grayscale) or in 24-bit (true color), but quite often the images eventually get transformed into 1-bit (two color) images.
The process of scanning images in 1-bit mode or transforming images to 1-bit mode requires the user to choose a threshold that will decide what is black and what is white. For instance, for a drawing scanned in grayscale (8-bit), the gray values of its pixels range from 0 (black) to 255 (white). To transform such an image to 1-bit mode, the user has to choose the gray value that will split those color values between black and white in the new image. That value could be set to 127, which would transform any pixel having a gray value lower than 127 to black, and the others to white. The threshold could also have a lower value such as 10, which would make most pixels except the very dark ones become white.
Because of various factors, such as the non-uniform nature of paper, ink, scanner response, etc., adjacent pixels that look the same may have slightly different gray values. Therefore, in the transformation process from grayscale to black and white, a set of pixels along a line may not all be transformed into the same color when transformed into 1-bit data. This leads to a common problem: the edges of lines on a drawing scanned or transformed into 1-bit mode are often characterized by random pixels that prevent the edges from being smooth and uniform. Pixels missing from an edge are called holes, and pixels added to an edge are called bumps. Those random holes and bumps along the edges are an undesired consequence of the various factors cited above.
FIG. 1A shows an exemplary grayscale image prior to conversion. The image consists of a character 102a, a character 104a and a curve 106a. FIG. 1B shows the same image converted to 1-bit color. The smooth characters 102a and 104a from FIG. 1A are now jagged characters 102b and 104b, respectively. Similarly, the smooth curve 106a becomes a jagged, stepped curve 106b in FIG. 1B.
FIG. 2A shows another exemplary grayscale image 200 prior to conversion to 1-bit color. FIG. 2B shows the same image 200 converted to 1-bit color. Holes in the lines are indicated, for example, by arrows 202a, 202b, 202c and 202d. Bumps are indicated, for example, by arrows 204a, 204b, and 204c. 
One approach to solving this problem is used by MicroStation™ IRAS/B available from Bentley Systems Inc. of Exton, Pa. IRAS/B has a tool called “Smooth” for repairing edges that have bumps and holes. However, IRAS/B can only fill or remove “single pixel” holes or bumps, i.e. holes or bumps where only one pixel is missing or added. That is a fairly limiting constraint, as those single pixels represent a minority of the noisy pixels encountered along edges.
An example of the result obtained using that IRAS/B is given in FIGS. 3A and 3B. FIG. 3A shows an exaggerated view of an edge 300 resulting from conversion to 1-bit color. The edge 300 has single bumps, for example bump 302, and multiple bumps, for example bump 304, which contains more than one pixel. Similarly, edge 300 has single holes, for example hole 306, and multiple holes, for example, hole 308, which is missing more than one pixel.
FIG. 3B shows the edge 300 after the application of the IRAS/B tool. The single bump 302 is removed and single hole 306 is filled, but the multiple bump 304 and multiple hole 308 remain un-smoothed.
What is needed then is an improved way of smoothing 1-bit color images that overcomes shortcomings of conventional solutions.